package com.applink.sell_proof;

import android.os.Bundle;

import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.applink.sell_proof.api.DataHelper;
import com.applink.sell_proof.util.Utility;

public class CreateClaim extends BaseClaim {

	@Override
	protected void onCreate(Bundle saveInstanceState) {
		super.onCreate(saveInstanceState);
		setTitle(getString(R.string.new_claim));
	}

	@Override
	protected void onResume() {
		super.onResume();
		int checkState = Utility.checkTimeValidation();
		switch (checkState) {
		case 0:
			Utility.showAlertDialogLogout(this,
					android.R.drawable.ic_dialog_alert,
					Utility.messageServerTimeOut, Utility.titleServerTimeOut,
					CreateClaim.this);
			break;
		case 1:
			Utility.showAlertDialogLogout(this,
					android.R.drawable.ic_dialog_alert,
					Utility.messageLocalTimeOut, Utility.titleLocalTimeOut,
					CreateClaim.this);
			break;

		default:
			break;
		}
		DataHelper.getInstance().addObserver(this);
	}

	@Override
	protected void onPause() {
		super.onPause();
		DataHelper.getInstance().deleteObserver(this);
	}

	public boolean onPrepareOptionsMenu(Menu menu) {

		MenuItem submit = menu.findItem(R.id.menu_submit_claim);
		MenuItem save = menu.findItem(R.id.menu_save_claim);
		submit.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
		save.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

		return super.onPrepareOptionsMenu(menu);
	}
}